package org.mat.ipaas.ucenter.bff.admin.modules.system;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.api.system.SysGatewayRouteRestAPI;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysGatewayRouteDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * gateway路由管理
 */
@Api(tags = "gateway路由管理")
@RestController
@RequestMapping("/sys/gatewayRoute")
@Slf4j
public class SysGatewayRouteController {

	@Autowired
	private SysGatewayRouteRestAPI sysGatewayRouteRestAPI;

    @PostMapping(value = "/updateAll")
    public MatApiResponse<?> updateAll(@RequestBody JSONObject json) {
		MatApiResponse<?> matApiResponse = sysGatewayRouteRestAPI.updateAll(json);
		return matApiResponse;
	}

	@GetMapping(value = "/list")
	public MatApiResponse<?> queryPageList(SysGatewayRouteDTO sysGatewayRouteDTO) {
		MatApiResponse<?> matApiResponse = sysGatewayRouteRestAPI.queryPageList(sysGatewayRouteDTO);
		return matApiResponse;
	}

	@GetMapping(value = "/clearRedis")
	public MatApiResponse<?> clearRedis() {
		MatApiResponse<?> matApiResponse = sysGatewayRouteRestAPI.clearRedis();
		return matApiResponse;
	}

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    //@RequiresPermissions("system:getway:delete")
    @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
    public MatApiResponse<?> delete(@RequestParam(name = "id", required = true) String id) {
		MatApiResponse<?> matApiResponse = sysGatewayRouteRestAPI.delete(id);
		return matApiResponse;
	}

}
